<?php
//抑制所有错误信息
@error_reporting(E_ALL &~ E_NOTICE);
@set_time_limit(0);
date_default_timezone_set('PRC');
if (!isset($_SERVER['PHP_SELF']) || empty($_SERVER['PHP_SELF'])) $_SERVER['PHP_SELF']=$_SERVER['SCRIPT_NAME'];
header('Content-type:text/html; charset=utf-8'); //强制语言
/*****************************************/
/*           程序自行获取的变量          */
/*****************************************/
define('ROOT',str_replace('\\','/',dirname(__FILE__)).'/');
define('MODEL',ROOT.'model/');
define('TPL',ROOT.'template/');
require(ROOT.'config.php');
require(ROOT.'common.func.php');
require(ROOT.'base.php');
/*****************************************/
/*                   其它                */
/*****************************************/
$_ENV=array();
$m=getgpc('m');
$a=getgpc('a');
$m=empty($m)?'index':$m;
$a=empty($a)?'body':$a;
if (in_array($m,array('index','member','sign','reply','setting','ban','del'),TRUE)) {
	if(is_file(MODEL.$m.'.php')) {
		require(MODEL.$m.'.php');
	} else {
		exit('Model not found!');
	}
	$m.='_model';
	$_ENV['_model']=$m::getInstance();
	//密码相关
	if (!isset($_COOKIE['sythpwd']) || $_COOKIE['sythpwd']!=PWD) {
		if ($m!='index_model' || ($m=='index_model' && !in_array($a,array('login','loginout'),TRUE))) {
			echo '<script>window.location.href="index.php?m=index&a=login";</script>';
			exit;
		}
	}
	$method='on'.$a;
	if(method_exists($_ENV['_model'],$method) && $a{0}!='_') {
		$_ENV['_model']->$method();
	} else {
		exit('Action not found!');
	}
} else {
	exit('Model not found!');
}
?>